package ext.vpde.cadvaulting.migration;

import java.io.*;
import java.sql.*;
import java.util.*;

import ext.vpde.cadvaulting.util.WINDSQL;
import wt.dataservice.*;

public class ScanUsageTypes {
	
	public static void main ( String [] args ) throws Exception {
		if (args.length != 1) {
			System.out.println("\nUsage: windchill ext.productcenter.ScanUsageTypes loadfile");
		} else {
			Class.forName(DSProperties.JDBC_DRIVER);
			String jdbcURL = DSProperties.JDBC_URL + "@" + DSProperties.SERVICE_NAME;
			WINDSQL.conn  = DriverManager.getConnection(jdbcURL,DSProperties.DB_USER,DSProperties.DB_USER);
			readEntries(args[0]);
			WINDSQL.conn.close();
		}
    }
	
	private static void readEntries(String LOADFILE) throws Exception {
		BufferedReader file = new BufferedReader(new FileReader(LOADFILE));
		String s = file.readLine();
		Hashtable ht = new Hashtable();
		while (s!= null && s.length() > 0) {	
			StringTokenizer strTok = new StringTokenizer(s,"|");
			String pName = strTok.nextToken();
			strTok.nextToken();
			strTok.nextToken();
			strTok.nextToken();
			String cName = strTok.nextToken();
			String pExt  = pName.substring(pName.indexOf(".")+1);
			String cExt  = cName.substring(cName.indexOf(".")+1);
			
			String both  = pExt + "-" + cExt;
			if (!ht.containsKey(both)) ht.put(both,both);

			s = file.readLine();
		}
		System.out.println(ht.toString());
	}
}
